home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form togglprt
- Caption = "Set Default Printer"
- ClientHeight = 1020
- ClientLeft = 1275
- ClientTop = 3270
- ClientWidth = 3720
- Height = 1425
- Icon = TOGGLPRT.FRX:0000
- Left = 1215
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 1020
- ScaleWidth = 3720
- Top = 2925
- Width = 3840
- Begin CommandButton ToggleBtn
- Caption = "ToggleBtn"
- Height = 375
- Left = 120
- TabIndex = 0
- Top = 480
- Width = 3495
- End
- Begin Label DefaultPrinter
- Alignment = 2 'Center
- Caption = "Default Printer"
- Height = 255
- Left = 120
- TabIndex = 1
- Top = 120
- Width = 3495
- End
- Const Cr = "Copyright JSS, Inc. 1992 - Steve Schiavo, Center Point, TX"
- Sub Form_Load ()
- HP2Default = Space$(128)
- FAXdefault = Space$(128)
- MaxSiz = 128
- 'Load constants HP2Default and FAXdefault w/precise description of two printers in .INI file
- '(Note: You must HAVE lines in your Win.Ini file for "HP2Key= . . ." and "FAXKey= . . .")
- NumChars% = GetProfileString("windows", "HP2Key", "", HP2Default, MaxSiz)
- NumChars% = GetProfileString("windows", "FAXKey", "", FAXdefault, MaxSiz)
- 'Invoke the core process for the first time
- WasMinimized = True
- ' Form_Resize
- End Sub
- Sub Form_Resize ()
- On Error GoTo FileError
- Current$ = Space$(128)
- MaxSiz = 128
- If NowMinimized() Then WasMinimized = True ' Record for future how it "last" was
- If WasMinimized And NowNormal() Then ' This means he "restored" it
- WasMinimized = False ' Record so we don't invoke when we minimize
- NumChars% = GetProfileString("windows", "device", "", Current$, MaxSiz)
- DefaultPrinter.Caption = "Current printer is " + Strip(Current$)
- If Current$ = HP2Default Then Target = FAXdefault Else Target = HP2Default
- ToggleBtn.Caption = ToggleTo + Strip(Target)
- End If
- Exit Sub
- FileError:
- MsgBox "Can't Open File", 16, Error$(Err)
- Resume Next
- End Sub
- Function NowMinimized () As Integer
- If WindowState = 1 Then NowMinimized = True Else NowMinimized = False
- End Function
- Function NowNormal () As Integer
- If WindowState = 0 Then NowNormal = True Else NowNormal = False
- End Function
- Function Strip (CommaString As String) As String
- x% = InStr(CommaString, ",")
- Strip = Left$(CommaString, x% - 1)
- End Function
- Sub ToggleBtn_Click ()
- NumChars% = WriteProfileString("windows", "device", Target)
- WindowState = 1 ' Minimize it
- x = DoEvents()
- End Sub
-